﻿using System;
using System.Collections.Generic;
using System.Text;

namespace _50.泛型方法
{
     class person
    {
        public void A()
        {
            Console.WriteLine("我跑起来了，哈哈");
        }
    }
    class ClassA<A>
    {
        public A Age { get; set; }
        public void Test(A c)
        {
            Console.WriteLine("我今年{0}岁",c);
        }
    }
    class ClassB<A, B>
    {
        private A _age;
        public A Age { get; set; }
        public  void b(A a,B b)
        {
            Console.WriteLine("我是{0}，我今年{1}岁",a,b);
        }
    }
    //泛型类的约束
    interface IlookAinterface
    {
        void MyLook();
    }
    //约束为值类型
    class LookA<A>where A:struct
    {
        public void Look(A a)
        {
            Console.WriteLine("看了几次？"+ a + "次");
        }
    }
    //约束为引用类型
    class LookB<B,C>where B:class where C:new()
    {
        public void Look(B b,C c)
        {
            if (b.ToString().Equals("_50.泛型方法.LookC"))
            {
                object obje = b;
                LookC d = (LookC)obje;
                d.Look1();
            }
            if (c.ToString().Equals("_50.泛型方法.LookD"))
            {
                object obj = c;
                LookD D = (LookD)obj;
                D.Look();
            }
            //Console.WriteLine(c.ToString());
           // Console.WriteLine(b.ToString());
        }
    }
    class LookC
    {
        public void Look1()
        {
            Console.WriteLine("跑起来了");
        }
    }
    class LookD
    {
       public void Look()
        {
            Console.WriteLine("臭弟弟");
        }
    }
    class LookE<C> : IlookAinterface where C :IlookAinterface 
    {
        public void MyLook()
        {
            Console.WriteLine("哦买噶");
        }
    }
    class LookF : IlookAinterface
    {
        public void MyLook()
        {
            Console.WriteLine("老第");
        }
    }
}
